/**
 * synchronized关键字
 * 对某个对象加锁
 *
 * @author mashibing
 */
package yxxy.c_001;

public class SynchronizedTest2 {

    private int count = 10;

    public void m() {

        /**
         * 锁定this这个对象
         */
        synchronized (this) {
            //任何线程要执行下面的代码，必须先拿到this的锁
            count--;
            System.out.println(Thread.currentThread().getName() + " count = " + count);
        }
    }

}

